package com.ms;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 集合是不允许有重复元素；
 * @author carter
 * create time    2018-08-20
 */
public class TestCollection1 {


    public static void main(String[] args) {

        Set<String> set = new HashSet<>();
        System.out.println(set.add("abc"));
        System.out.println(set.add("xyz"));
        System.out.println(set.add("abc"));

        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext())
        {
            String item = iterator.next();

            System.out.println(item);
        }


    }


}


